from django.db import models

# Create your models here.

# 创建图书表
class Book(models.Model):
    # 标题
    title = models.CharField(max_length=32)
    # 价格
    price = models.IntegerField()
    # 简介
    desc = models.TextField()
    # 封面链接
    cover = models.CharField(max_length=255)
    # 图书链接
    link =models.CharField(max_length=255)
    # 出版日期
    publish_date = models.DateTimeField(auto_now_add=True)

    publish = models.ForeignKey(to="publish.Publish", on_delete=models.CASCADE)
    author = models.ManyToManyField(to="author.Author")
    class Meta():
        db_table = "book"
        verbose_name_plural = "图书表"

    def __str__(self):
        return f"这是 {self.title} 图书对象!"
